package cn.school.fiter;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

@WebFilter(value = "/*", filterName = "a")
public class Fiter implements javax.servlet.Filter {
    public Fiter() {
    }

    @Override
    public void destroy() {

    }

    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
            throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) arg0;// 强转
        System.out.println("当前访问路径：" + req.getServletPath());// 请求地址
        req.setCharacterEncoding("utf-8");
        arg2.doFilter(arg0, arg1);// 放行！！！
        return;
    }

    @Override
    public void init(FilterConfig arg0) throws ServletException {
        System.out.println("filter init ");
    }
}

